package edu.sctu.zhoudie.mouth201506.day20150602;

import java.util.Calendar;

/**
 * Created by 08 on 2015-06-07.
 */
public class praictice {
    /**
         * @param args
         */
   public static void main(String[] args) {
        //获得日历对象
      Calendar c = Calendar.getInstance();
        System.out.println(c.get(Calendar.YEAR));
         System.out.println(c.get(Calendar.DATE));
        c.setFirstDayOfWeek(Calendar.MONDAY);
         //显示当前的日期和各个分量
      display(c);

             //设置日期和时间
             c.set(2012, 11, 23);
           c.set(Calendar.HOUR, 10);
           c.set(Calendar.MINUTE, 4);
              c.set(Calendar.SECOND, 54);
            System.out.println("更新后的时间：");
               display(c);

             //调整日期和时间
             c.add(Calendar.DATE, 10); //意思是把当前日期加上10天
               c.add(Calendar.HOUR_OF_DAY, 10);//意思是把当前时间加上10个小时

          }

             public static void display(Calendar c){
                String month[]={"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"};
         String days[]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
              System.out.print("日期：");
            System.out.print(c.get(Calendar.YEAR )+"年");
                System.out.print(month[c.get(Calendar.MONTH)]);
              System.out.print(c.get(Calendar.DATE )+"日 ");
               System.out.println(days[c.get(Calendar.DAY_OF_WEEK)-1]);
                System.out.print("时间：");
               System.out.print(c.get(Calendar.HOUR)+":");
               System.out.print(c.get(Calendar.MINUTE)+":");
             System.out.println(c.get(Calendar.SECOND));
          }


}
